<{assign var="tpl_page_title" value="商品详情"}>
<{include file="mobile/block/header.html"}>
<section id="" class="page_center_box">
<div class="banner" style="padding:0px;">
	<ul>
		<{foreach $product_photo_list as $v}>
		<li><img src="<{$pager.img}>/<{$v.photo}>"/></li>
		<{/foreach}>
	</ul>
	<span class="identify"><{foreach $product_photo_list as $v}><em></em><{/foreach}></span> </div>
<div class="zxCompany_intro">
	<div class="nrBox mb10">
		<div class="nr lh30">
			<h1><{$detail.title}></h1>
			<p><b class="fontcl2" id="product_spec_price">￥<{$detail.price}></b>&nbsp;<del class="black9">￥<{$detail.market_price}></del></p>
			<a href="<{link ctl='mobile/shop' arg0=$detail.shop_id}>" class="long_btn">进入店铺</a> </div>
	</div>
	<div class="nrBox mb10">
		<div class="nr lh30">
			<input type="hidden" id="product_spec_id" value="0" />
			<{if $detail.sale_type == 1}>
			<p>库存：<font class="pointcl" id="product_sale_sku"><{$detail.sale_sku-$detail.sale_count|default:'缺货'}></font></p>
			<{else}>
			<p>库存：<font class="pointcl" id="product_sale_sku"><{$detail.store|default:'缺货'}></font></p>
			<{/if}>
			<p>分类：<{$detail.cate_name}></p>
			<{if $product_spec_list}>
			<p class="goods_guig" id="product_spec_list">规格：<{foreach $product_spec_list as $v}><a href="javascript:;" spec_id="<{$v.spec_id}>"><{$v.spec_name}> <i class="app_ico"></i></a><{/foreach}></p
    >
			<{/if}>
			<p>数量：<a class="jian count_ico" quantity="-"></a>
				<input type="text" id="cart_product_num" class="buy_count_text" value="1" />
				<a class="jia count_ico" quantity="+"></a></p>
		</div>
	</div>
	<div class="applyDesign"> <{if $detail.onsale == 'Y' && $detail.onpayment}> <a href="javascript:;" cart="buy:<{$detail.product_id}>" id='sku_show' class="btn">立即购买</a> <{/if}> <a href="<{link ctl='mobile/product:yuyue' arg0=$detail.product_id}>"  class="btn">预约购买</a></div>
	<div class="nrBox mb10">
		<div class="nr lh30">
			<h2><{$detail.name}></h2>
			<p><span class="fl"><b class="fontcl2">￥<{$detail.price}></b>&nbsp;<del class="black9">￥<{$detail.market_price}></del></span><a href="#" class="fr btn pdBtn">预约购买</a></p>
			<div class="clear"></div>
		</div>
	</div>
	<div class="nrBox mb10">
		<h3>商品详情</h3>
		<div class="nr">
			<div class="article"><{$fields.info}></div>
		</div>
	</div>
</div>
<script type="text/javascript" src="%THEME%/mobile/static/script/flipsnap.min.js"></script> 
<script type="text/javascript" src="%THEME%/mobile/static/script/banner.js"></script> 
<script type="text/javascript">
var product_sale_sku = <{if $detail.sale_type==1}><{$detail.sale_sku-$detail.sale_count}><{else}><{$detail.store|default:0}><{/if}>;
$(document).ready(function(){
    $.KT.initBanner(".banner", 0.66, true,5000);   
    $("[quantity]").click(function(){
        var quantity = parseInt($("#cart_product_num").val(), 10);
        if($(this).attr("quantity") == '+'){
            if(product_sale_sku <= quantity){
                Widget.MsgBox.notice("库存不足");
                return false;
            }else{
                quantity += 1;
            }
        }else{
            quantity -= 1;
        }
        if(quantity < 1){
            quantity = 1;
        }
        $("#cart_product_num").val(quantity);
    });
});
<{if $product_spec_list}>
var product_spec_list = [];
<{foreach $product_spec_list as $item}>
product_spec_list.push(["<{$item.spec_id}>", "<{$item.price}>", "<{$item.spec_name}>", "<{$item.spec_photo}>", <{$item.sale_sku}>, <{$item.sale_count}>]);
<{/foreach}>
var spec_max_price = spec_min_price = "<{$detail.price}>";
for(var i=0; i<product_spec_list.length; i++){
    if(spec_max_price < product_spec_list[i][1]){
        spec_max_price = product_spec_list[i][1];
    }
    if(spec_min_price > product_spec_list[i][1]){
        spec_min_price = product_spec_list[i][1];
    }    
}
$("#product_spec_price").html("￥"+spec_min_price+" - ￥"+spec_max_price);

$("#product_spec_list a").click(function(){
    var spec_id = $(this).attr("spec_id");
    $("#product_spec_list a").removeClass("current");
    $(this).addClass('current');
    for(var i=0; i<product_spec_list.length; i++){
        if(product_spec_list[i][0] == spec_id){
            $("#product_spec_price").html("￥"+product_spec_list[i][1]);
            $("#product_spec_id").val(spec_id);
			if(product_spec_list[i][4]-product_spec_list[i][5]<=0){
				var kc = '缺货';
				$("#sku_show").hide();
			}else{
				var kc = product_spec_list[i][4]-product_spec_list[i][5];	
				$("#sku_show").show();
			}
			$("#product_sale_sku").html(kc);
            break;
        }
    }    
});
$("#product_spec_list a").eq(0).click();
<{/if}> 
$("[cart]").click(function(e){
    var link = "<{link ctl='mobile/trade/cart:add' arg0=$detail.product_id arg1='#spec#' arg2='#num#' http='base'}>";
    var num = parseInt($("#cart_product_num").val(), 10);
    var spec_id = parseInt($("#product_spec_id").val(), 10);
    <{if $product_spec_list}>
        if(spec_id < 1){Widget.MsgBox.notice("没有选择商品规格");return false;}
    <{/if}>
	var kc = $("#product_sale_sku").html();
	if(kc == '缺货' || kc=='0'){
        Widget.MsgBox.notice("缺货");
		return false;
	}
    var d = $(this).attr("cart").split(":")
    $.getJSON(link.replace("#spec#", spec_id).replace("#num#", num), function(ret){
        if(ret.error){            
            Widget.MsgBox.load(ret.message.join(","));
            Widget.MsgBox.error(ret.message.join(","));
        }else{
            Widget.MsgBox.success('添加到购物车成功');
            window.location = "<{link ctl='mobile/trade/cart' http='base'}>";
        }

    });
});
</script> 
<{include file="mobile/block/footer.html"}> 